package com.lancoo.ccas52.schedues;

import cn.hutool.core.util.StrUtil;
import com.lancoo.ccas52.pojo.constant.GlobalConstant;
import com.lancoo.ccas52.pojo.response.basicPlatform.SubSystemsMainServer;
import com.lancoo.ccas52.service.YunBasicService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @ClassName InitParam
 * @Description TODO
 * @Author quin
 * @Date 2023/12/18 9:47
 */
@Component
@Slf4j
@EnableAsync(proxyTargetClass = true)
public class InitParam {

    @Resource
    private YunBasicService yunBasicService;

    @Scheduled(cron = "0 0 * * * ?")
    public void initAccessPath() {
        //初始化后端访问路径
        SubSystemsMainServer e31 = yunBasicService.getSubSystemsMainServer("E31",false);
        //e31有数据时再进行更新
        if (StrUtil.isNotEmpty(e31.getWsSvrAddr())) {
            GlobalConstant.ACCESS_PATH = e31.getWsSvrAddr();
        }else {
            log.error("初始化后端访问路径失败，路径为空");
        }

    }
}
